package com.yuanthink.gwt.client.modules.user.member.actions;

import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.yuanthink.gwt.client.actions.IAction;
import com.yuanthink.gwt.client.eventbus.EventBus;
import com.yuanthink.gwt.client.modules.user.member.presenters.MemberListPresenter;
import com.yuanthink.gwt.client.registry.GeneralRegistry;

/**
 * @author 06peng
 *
 */
public class MemberListAction implements IAction {

	private EventBus eventBus;
    MemberListPresenter presenter = null;

    public MemberListAction(EventBus eventBus) {
        this.eventBus = eventBus;
    }
	
	@Override
	public void execute(ModelData data) {
		ContentPanel container = (ContentPanel) GeneralRegistry.get("mainArea");
		if (container == null) {
			MessageBox.alert("Debug information", "container==null", null);
			return;
		}
		container.removeAll();
		container.setLayout(new FitLayout());
		if (presenter == null) {
			presenter = new MemberListPresenter(eventBus);
		}
		presenter.go(container);
	}

	@Override
	public boolean shouldAddToHistory() {
		return true;
	}

}
